home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cl_7_bug.zip / BUG_3.C < prev    next >
C/C++ Source or Header  |  1992-10-10  |  955b  |  40 lines

  1. /*
  2.   Test if intrisinic strlen with doesn't work
  3.   This code works if errmesg isn't near.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <malloc.h>
  8.  
  9. void print_name(int textnr,char * name,char * formname);
  10. void pack_filename(char * to,char * from,int length);
  11.  
  12. #define ER(X) errmesg[(X)-3000]
  13.  
  14. int  s_width=80;
  15. extern char ** near errmesg=0;
  16.  
  17. int main(int argc,char *argv[])
  18. {
  19.   errmesg=(char**) malloc(sizeof(char *)*200);
  20.   errmesg[118]="Formulär: %s";
  21.   errmesg[123]="Register: %s  %s";
  22.  
  23.   puts("The following text should be: 'Register: reg(50)  Formulär: form'");
  24.   print_name(3123,"reg","form");
  25.   puts("");
  26.   return 0;
  27. }
  28.  
  29. void print_name(int textnr,char * name,char * formname)
  30. {
  31.   unsigned int length;
  32.   char buff2[81],b_name[81];
  33.  
  34.   sprintf(buff2,ER(3118),formname);
  35.   length=strlen(buff2);
  36.   sprintf(b_name,"%s(%d)",name,s_width-strlen(ER(textnr))-length);
  37.   printf(ER(textnr),b_name,buff2);
  38.   return;
  39. } /* print_name */
  40.